<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<%
	request.setAttribute("title", "注册");
%>
<%@ include file="/WEB-INF/views/shared/master/weContentHeader.jsp"%>
<style type="text/css">
  body{
  	background-image:url("<c:url value='/images/we/appShareRegister/bg1.png' />");
	background-size: 100%;
	}
	.forInput{
		background-color: rgba(0,0,0,0.0);
		color: #ffffff;
		border-radius: 20px;
		
		font-size: 0.8rem;
	}
	.forPhone{
		padding: 15px;
		width: 70%;
		border: 1px solid #ffffff; 	
	}
	.forTest{
		padding:0.6rem 0.1rem 0.6rem 0rem; 
		width: 77%;
		margin-top:1rem;
		border: 1px solid #ffffff; 	
		display: inline-block;	
	}
	.forTestInput{
		border: 0px;
	}
	.forInput::-webkit-input-placeholder {
    	color:#ffffff;
    	font-size: 0.8rem;
	}
	.forButton{
		width: 78%;
		margin-top: 1rem;
		background-color: #ffffff;
		color: #000000;
		font-size: 0.9rem;
		padding: 10px;
		border-width: 0px;
	}
	
	.btn-text{
		background-color: rgba(0,0,0,0);
		color:#ffffff;
		border:0px;
		display: inline-block;
		width: 2.5rem;
	}
</style>
<div style="text-align: center;">
	<img style="width: 50%;margin-top: 1rem" alt="" src="<c:url value='/images/we/appShareRegister/redister.png' />">	
</div>
<input value="${identity}" id="identity" hidden/>
<div style="text-align: center;margin-top: 2rem">
	<div style="text-align: center;">
		<div class="forTest forInput">
			<input id="phone" class="forInput forTestInput"  placeholder="请输入手机号" onBlur="checkPhone()"/>
			<span  class="btn-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
		</div>
	</div>
	
	<div style="text-align: center;">
		<div class="forTest forInput">
			<input class="forInput forTestInput" id="code" placeholder="请输入验证码"/>
			<span id="btn-get" class="btn-text" onclick="getCode()">获取</span>
		</div>
	</div>
	
	<button class="forInput forButton" onclick="submit()">
		确定
	</button>	
	
</div>



<%@ include file="/WEB-INF/views/shared/scripts/jquery.jsp"%>
<%@ include file="/WEB-INF/views/shared/scripts/jqweui.jsp"%>

<script type="text/javascript">

	function submit(){
		var url = $.getVirtualPath()+"/wechat/cust/appShareRegister/registeredNow?phone="+$("#phone").val()+"&code="+$("#code").val();
		var result = $.getJson(url);
		if(result.status=="200"){
			alert(result.message);
			window.location.href=$.getVirtualPath()+"/wechat/cust/appShareRegister/download";
		}else{
			alert(result.message);
		}
	}


/* 发送验证码 */
function getCode(){
	if(checkPhone()){
		sendMessage();
	}else{
		$('#phone').focus();
	}
}

function sendMessage(){
    var phoneNum = $("#phone").val();
    sendMessagePhone = phoneNum;
    var url=$.getVirtualPath()+"/wechat/cust/customerIden/sendMessage";
    $.getText(url,"phone="+phoneNum);
	setCountdown();
}

/* 发送验证码倒计时 */
var countdown=60; 
function setCountdown() {
	var $btnSend = $("#btn-get");
    if (countdown == 0) { 
    	$btnSend.attr('disabled',false); 
    	$btnSend.text("获取");
        countdown = 60; 
        return;
    }
    $btnSend.attr('disabled',true);
    $btnSend.text(countdown + "s");
    countdown--;
    setTimeout(function() { setCountdown($btnSend) },1000)
}

/* 验证手机号码 */
function checkPhone(){
	var phone = $('#phone').val();
	var pattern = /^1[0-9]{10}$/;
	if(phone == '') {
		$.toptip("请输入手机号码","error");
		return false;
	}else if(!pattern.test(phone)){
		$.toptip("请输入正确的手机号码","error");
		return false;
	}
	return true;
}
</script>

<%@ include file="/WEB-INF/views/shared/master/weContentFooter.jsp"%>
